home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
usenet
/
sources
/
volume90
/
kernel
/
xoper_22
/
part03
/
Xoper.a.ab
Wrap
Text File
|
1990-02-01
|
53KB
|
2,501 lines
signal bsr readhex
tst.b d7
beq syntax
setthem move.l d0,savedat
bsr nodenam
moveq.l #2,d7
lea TReNode(PC),a4
bsr findnam
tst.b d7
beq.s pi1
move.l d0,a1
move.l savedat,d0
and.l 18(a1),d0
CALL Signal,_SysBase(PC)
rts
;set up a list of tasknames which should't be displayed
hide cmp.b #10,0(a0)
bne.s hid5
bra syntax
hid5 lea hidestart(PC),a2
move.l a2,d3
hid0 tst.l 0(a2)
beq.s hid1
move.l 0(a2),a2
lea 4(a2),a1
bsr strcmp
tst d0
beq.s hid2
move.l a2,d3
bra.s hid0
hid1 move.l a0,a4
bsr strlen2
addq #5,d0
move.l #65536,d1
CALL AllocMem,_SysBase(PC)
tst.l d0
beq.s hid4
move.l d0,a1
move.l d0,0(a2)
addq #4,a1
hid3 cmp.b #10,0(a4)
beq.s hid4
move.b (a4)+,(a1)+
bra.s hid3
hid4 rts
hid2 move.l d3,a3
move.l 0(a2),0(a3)
freehidden lea 4(a2),a0
bsr strlen
addq #5,d0
move.l a2,a1
CALL FreeMem,_SysBase(PC)
rts
freehidmem move.l hidestart(PC),a4
fhm0 move.l a4,d0
beq.s fhm1
move.l a4,a2
move.l 0(a2),a4
bsr freehidden
bra fhm0
fhm1 rts
;set up an ALIAS list
alias cmp.b #10,0(a0)
beq showalias
bsr strbuf
move.l a0,a5
lea buffer,a0
bsr strlen
tst.l d0
beq syntax
moveq #1,d1
cmp d1,d0
bne.s 5$
lea params(PC),a0
moveq #parmnum-1,d1
move.b buffer,d2
6$ cmp.b (a0)+,d2
dbeq d1,6$
tst.w d1
bmi.s 5$
move.l #aliaserr,d0
bsr putstr
move.l #params,d0
bsr putstr
move.l #aliaserr2,d0
bra putnam
5$ move.l d0,d5
move.l a5,a0
adda.l d0,a0
bsr kllblnks
move.l a5,-(a7)
bsr findcmd
move.l (a7)+,a5
tst.l d2
bmi syntax
move.l a5,a0
bsr strbuf
addq #6,d5
move.l d5,d0
move.l #65536,d1
CALL AllocMem,_SysBase(PC)
tst.l d0
beq.s 1$
move.l aliaslist(PC),d1
bne.s 2$
move.l d0,aliaslist
bra.s 3$
2$ move.l d1,a0
move.l 0(a0),d1
bne.s 2$
move.l d0,0(a0)
3$ move.l d0,a0
move.b d2,4(a0)
lea 5(a0),a0
lea buffer,a1
4$ move.b (a1)+,(a0)+
bne.s 4$
1$ rts
showalias lea alhead(PC),a0
bsr puthead
move.l aliaslist(PC),d0
beq.s 1$
2$ move.l d0,a5
addq #5,d0
bsr putstr
move.w #15,d1
bsr tab
move.l #equal,d0
bsr putstr
move.b 4(a5),d0
ext.w d0
bsr getcmdptr
bsr putnam
move.l 0(a5),d0
bne.s 2$
1$ rts
freealias move.l aliaslist(PC),a4
1$ move.l a4,d0
beq.s 2$
move.l a4,a2
move.l 0(a2),a4
lea 5(a2),a0
bsr strlen
addq #6,d0
move.l a2,a1
CALL FreeMem,_SysBase(PC)
bra 1$
2$ rts
getcmdptr move.l a0,-(a7)
lea commds(PC),a0
2$ tst d0
beq.s 1$
3$ tst.b (a0)+
bne.s 3$
subq #1,d0
bra.s 2$
1$ move.l a0,d0
move.l (a7)+,a0
rts
;'flushlibs'
flush move.l #$ffffff,d0
moveq #0,d1
CALL AllocMem,_SysBase(PC)
flsh1 rts
;display library->lib_IDString
info bsr nodenam2
moveq.l #2,d7
lea DevNode(PC),a4
bsr findnam
tst.b d7
beq.s flsh1
move.l d0,a0
move.l 24(a0),d0
beq.s if1
move.l d0,d1
andi.l #1,d1
bne.s if1
bra putnam
if1 move.l #noinfo,d0
bsr putstr
move.l a5,d0
bra putnam
capture move.l _SysBase(PC),a1
lea 42(a1),a0
moveq #2,d6
lea coldtxt,a4
cap0 move.l a4,d0
bsr putstr
move.l 0(a0),d0
bne.s cap1
move.l #unset,d0
bsr putstr
bra cap2
cap1 bsr hexa
cap2 bsr newline
lea 15(a4),a4
addq #4,a0
dbf d6,cap0
move.l #kicktxt,d0
bsr putstr
move.l 546(a1),a0
cmpa.l #0,a0
bne.s kickm3
move.l #unset,d0
bra putnam
kickm3 move.l a0,-(a7)
bsr newline
lea kickhead(PC),a0
bsr puthead
move.l (a7)+,a0
kickm0 move.l a0,d0
beq kickm4
bpl.s kickm1
bclr #31,d0
move.l d0,a0
bra.s kickm0
kickm1 move.w 14(a0),d6
subq #1,d6
lea 16(a0),a2
kickm2 move.l 0(a2),d0
bsr hexa
move.l 0(a2),d0
move.l 4(a2),d4
add.l d4,d0
bsr hexa
move.l d4,d0
clr.b d3
bsr longdec
bsr newline
addq #8,a2
dbf d6,kickm2
move.l 0(a0),a0
bra kickm0
kickm4 rts
clrcold move.l _SysBase,a0
clr.l 42(a0)
bra.s chksum
clrcool move.l _SysBase,a0
clr.l 46(a0)
bra.s chksum
clrwarm move.l _SysBase,a0
clr.l 50(a0)
chksum lea 34(a0),a1
move #22,d0
addchk add (a1)+,d1
dbf d0,addchk
not d1
move.w d1,82(a0)
rts
;Save the command line to be repeated. If this line doesn't produce
;any output, don't repeat it at all
repeatcmd tst.w repeat
bne.s 2$
move.w repeatlen(PC),d0
subq #7,d0
move.w d0,repeatlen
lea repeatbuffer,a1
lea dummy,a2
move.w d0,d1
ext.l d1
1$ move.b 0(a0),(a1)+
move.b (a0)+,(a2)+
dbf d1,1$
clr.l lastprinted
clr.b printed
move.w #1,repeat
bsr cli
tst.b printed
beq.s 2$
bsr starttimer
rts
2$ clr.w repeat
rts
;save the parameters from a 'window x y width height' call
setwindow tst.b fromfile
bne.s wiw1
wiw3 move.l #wiwerr,d0
bra putnam
wiw1 lea window_l(PC),a3
moveq #3,d5
wiw0 bsr getnum
tst d7
beq.s wiw2
move.w d2,0(a3)
addq #2,a3
dbf d5,wiw0
wiw2 rts
;display ExecBase->LastAlert
lastalert movem.l $100,d1-d2
tst.l d1
bne.s al1
move.l _SysBase(PC),a0
movem.l 514(a0),d1-d2
al1 move.l #gurutxt,d0
bsr putstr
move.l d1,d0
bsr hexa
lea out,a0
move.l ptr(PC),d0
move.b #'.',-1(a0,d0)
move.l d2,d0
bsr hexa
bra newline
;toggle CLI-Commands
clicmd bchg #0,cmdcli
rts
;toggle CPUSE task list
usage bchg #0,usageflag
rts
;toggle task-header display on/off
nohead bchg #0,headon
rts
;toggle hide entries on/off
hidden bchg #0,hideon
rts
;toggle sort on/off
sort bchg #0,sorton
rts
;toggle task-ports display on/off
taskports bchg #0,tports
clo1 rts
;Open a library
openlib bsr nodenam2
move.l a5,a1
moveq #0,d0
CALL OpenLibrary,_SysBase(PC)
tst.l d0
beq fn5
opli1 rts
;close it
closelib bsr nodenam2
moveq #0,d7
lea LibNode(PC),a4
bsr findnam
tst.b d7
beq.s clo1
move.l d0,a1
CALL CloseLibrary,_SysBase(PC)
rts
remnode bsr nodenam2
moveq #7,d7
lea TReNode(PC),a4
bsr findnam
tst.b d7
beq.s 1$
CALL Disable,_SysBase(PC)
move.l d0,a1
CALL Remove,_SysBase(PC)
CALL Enable,_SysBase(PC)
1$ rts
;end Xoper but stay in background
quithold lea in,a0
lea dummy,a1
qh1 move.b (a1)+,d0
move.b d0,(a0)+
cmp.b #10,d0
bne.s qh1
instback tst.b background
bne.s cleanit
move.b #1,background
bsr installh
cleanit move.l infile(PC),d1
beq.s ib1
CALL Close,dosbase(PC)
clr.l infile
clr.b fromfile
ib1 clr.b running
bsr killpage
bsr freeblank
tst.l wnptr
beq.s 5$
tst.b ownscreen
bne.s 6$
move.l wnptr(PC),a0
move.l 4(a0),window_l
move.l 8(a0),window_w
6$ move.l wnptr(PC),a0
CALL CloseWindow,intuibase(PC)
clr.l intuimsg
clr.l wnptr
5$ move.l screenptr(PC),d0
beq.s 4$
move.l d0,a0
CALL CloseScreen,intuibase(PC)
clr.l screenptr
move.l realstack(PC),a7
4$ tst.b iconifyon
beq.s 1$
jsr iconify
bra.s 2$
1$ move.l mysignal(PC),d0
or.l trapsignal(PC),d0
CALL Wait,_SysBase(PC)
2$ move.b #1,running
and.l trapsignal(PC),d0
beq.s 3$
move.b #1,gotguru
3$ bra restart
;fill all unused memory-chunks with a longword
clear moveq #0,d0
cmp.b #10,0(a0)
beq.s clr5
bsr readhex
tst.b d7
beq syntax
clr5 move.l _SysBase(PC),a0
clr.l parmtxt
lea 322(a0),a0
move.w #$4000,$dff09a
clr1 move.l 0(a0),a0
tst.l 0(a0)
beq.s clr6
move.l 16(a0),a1
clr2 tst.l 0(a1)
beq.s clr1
addq.l #1,parmtxt
move.l 4(a1),d1
subq.l #8,d1
ble.s clr31
lsr.l #2,d1
subq.l #1,d1
bmi.s clr31
lea 8(a1),a2
clr3 move.l d0,(a2)+
dbf d1,clr3
clr31 move.l 0(a1),a1
bra.s clr2
clr6 move.w #-$4000,$dff09a
move.l parmtxt(PC),d0
bsr longdec
move.l #clrtxt,d0
bra putnam
;change the number of maximum lines in the history buffer
historylines
bsr getnum
tst.b d7
beq syntax
move.w d2,maxhlines
move.w hnum(PC),d0
1$ cmp.w maxhlines(PC),d0
ble.s 2$
bsr remhistline
subq #1,d0
bra.s 1$
2$ move.l history+8,curhist
move.w d0,hnum
rts
;set the minimum number of characters a input line
;must have to be added to the history buffer
historylength
bsr getnum
tst.b d7
beq syntax
tst.b d2
bne.s 1$
addq #1,d2
1$ move.w d2,minnumchars
rts
;display all lines in the history buffer
showhistory move.l history(PC),a5
moveq #1,d5
1$ tst.l 0(a5)
beq.s 2$
move.l d5,d3
bsr bytedec
move.w 8(a5),d0
ext.l d0
lea 10(a5),a0
lea inputbuffer,a1
CALL CopyMem,_SysBase(PC)
move.w 8(a5),d0
lea inputbuffer,a1
clr.b 0(a1,d0.w)
move.l a1,d0
bsr putnam
addq #1,d5
move.l 0(a5),a5
bra.s 1$
2$ rts
;set the maximum lines the output buffer may hold
outputlines bsr getnum
tst.b d7
beq syntax
moveq #100,d3
tst.l d2
bmi.s 2$
cmp.l d3,d2
bge.s 1$
2$ move.l d3,d2
1$ move.l d2,maxlines
rts
;find a named node
;d7 = number of lists to search through
;a4 = pointer to the first entry in the
; list-offset-table
;a5 = pointer to name
;returns:
;d7 = TRUE/FALSE 1/0
;d0 = node
findnam tst.b 0(a5)
bne.s 1$
move.l #nameerr,d0
bsr putnam
bra fnerr
1$ cmp.b #'$',0(a5)
bne.s fn2
move.l d7,d2
move.l a5,a0
bsr readhex
tst.b d7
beq.s fn6
move.l d2,d7
bsr tstnode
tst.l d5
bne.s fn3
bra fn5
fn6 move.l d2,d7
fn2 move.l _SysBase(PC),a0
adda.l 0(a4),a0
move.l a5,a1
fn4 CALL FindName,_SysBase(PC)
tst.l d0
bne.s fn1
addq #4,a4
dbf d7,fn2
fn5 move.l #namerr,d0
bsr putstr
move.l a5,d0
bsr putnam
fnerr clr.b d7
rts
fn1 move.b procnum(PC),d2
beq.s fn3
move.l d0,a0
cmp.b 143(a0),d2
bne.s fn4
fn3 moveq.l #1,d7
rts
;list-offset-table
TRuNode dc.l 276
TReNode dc.l 406
TWaNode dc.l 420
DevNode dc.l 350
LibNode dc.l 378
ResNode dc.l 336
MemNode dc.l 322
PorNode dc.l 392
SemNode dc.l 532
;Node has been entered in hex. Check if this node exsists
tstnode tst.b fromfile
bne.s illegalhex
move.l d0,d1
btst #0,d1
beq.s inrange
move.l #adrerr,d0
bsr putnam
illegalhex moveq #0,d5
rts
inrange movem.l d7/a4,-(a7)
cmp.l #TRuNode,a4
bne.s inrange1
move.l _SysBase(PC),a0
cmp.l 276(a0),d0
beq.s nodefound
subq #1,d7
addq #4,a4
inrange1 move.w #$4000,$dff09a
getlist move.l _SysBase(PC),a0
add.l 0(a4),a0
nxtnode tst.l 0(a0)
beq.s nxtlist
cmp.l a0,d0
beq.s nodefound
move.l 0(a0),a0
bra.s nxtnode
nxtlist addq #4,a4
dbf d7,getlist
move.w #-$4000,$dff09a
movem.l d0/d7/a4,-(a7)
bsr ResumeOutput
move.l #noderr,d0
bsr putnam
bsr readline
movem.l (a7)+,d0/d7/a4
cmp.b #'y',inputbuffer
beq.s nodefound1
moveq #0,d5
movem.l (a7)+,d7/a4
rts
nodefound move.w #-$4000,$dff09a
nodefound1 move.b #1,d5
etst movem.l (a7)+,d7/a0
rts
;allocate FileInfoBlock
allocfinfo move.l #260,d0
moveq #0,d1
CALL AllocMem,_SysBase(PC)
move.l d0,finfoptr
rts
;free FileInfoBlock
freefinfo move.l #260,d0
move.l finfoptr(PC),d1
beq.s 1$
move.l d1,a1
CALL FreeMem,_SysBase(PC)
1$ rts
;Examine ,d0=Lock
getfinfo move.l d0,d1
move.l finfoptr,d2
CALL Examine,dosbase(PC)
rts
;construct a Pathname from a lock
;d0=Lock ,resulting string is written to window
getpath movem.l d1-d7/a0-a6,-(a7)
move.l d0,d1
beq.s 1$
CALL DupLock,dosbase(PC)
1$ lea out,a4
clr.b -(a4)
gp0 move.l d0,-(a7)
bsr getfinfo
move.l finfoptr,a0
move.l 4(a0),d4
addq #8,a0
bsr strlen
lea -1(a4),a5
tst.l d4
bmi.s nodir
move.b #'/',-(a4)
nodir subq #1,d0
bmi.s nofnam
gp1 move.b 0(a0,d0),-(a4)
dbf d0,gp1
nofnam move.l 0(a7),d1
CALL ParentDir,dosbase(PC)
move.l d0,d4
move.l (a7)+,d1
beq.s 2$
CALL UnLock,dosbase(PC)
2$ move.l d4,d0
bne gp0
putall cmp.b #'/',0(a5)
bne.s gp2
move.b #':',0(a5)
gp2 move.l a4,d0
bsr putnam
movem.l (a7)+,d1-d7/a0-a6
rts
strlen move.l a0,-(a7)
moveq #-1,d0
strl2 addq.l #1,d0
tst.b (a0)+
bne.s strl2
move.l (a7)+,a0
rts
strlen2 move.l a0,-(a7)
move.l #-1,d0
strl22 addq.l #1,d0
cmp.b #10,(a0)+
bne.s strl22
move.l (a7)+,a0
rts
;write a title and underline
;a0 = pointer to text
puthead1 bsr strlen
move.l d0,d5
move.l a0,d0
bra putstr
puthead2 bsr strlen
add.l d0,d5
bra.s ph2
puthead bsr strlen
move.l d0,d5
ph2 move.l a0,d0
bsr putnam
lea out,a0
move.l a0,d0
ph1 move.b #'-',(a0)+
dbf d5,ph1
move.b #$0a,(a0)+
clr.b 0(a0)
bra putstr
;move cursor to a column
;d0 = current position
;d1 = column
tab move.l a3,-(a7)
lea out,a3
sp5 cmp.b d1,d0
bcc.s sp4
move.b #' ',0(a3,d0)
addq.b #1,d0
bra.s sp5
sp4 move.l d1,ptr
move.l (a7)+,a3
rts
;convert ascii to byte
;a0 = pointer to text
;d0 = byte
getnum cmp.b #'$',0(a0)
bne.s isdec
bsr readhex
move.l d0,d2
rts
isdec moveq #0,d2
move.l d2,d3
move.l d2,d6
move.l d2,d7
cmp.b #'-',0(a0)
bne.s gn1
addq #1,a0
moveq.l #1,d6
gn1 move.b (a0)+,d3
cmp.b #'9',d3
bhi.s gn2
cmp.b #'0',d3
bcs.s gn2
moveq #1,d7
and.b #$f,d3
muls #10,d2
add.l d3,d2
bra.s gn1
gn2 tst.b d6
beq.s gn3
neg.l d2
gn3 tst.b d7
bne.s gn4
subq #1,a0
gn4 rts
getfrac bsr isdec
muls #10,d2
cmp.b #'.',-1(a0)
bne.s 1$
moveq #0,d0
move.b (a0)+,d1
cmp.b #10,d1
beq.s 1$
and.b #15,d1
add.l d1,d2
1$ rts
;convert hex to longword
;a0 = pointer to text
;returns d0=value
;d7 = ok/error 1/0
readhex movem.l d1-d6/a1-a5,-(a7)
moveq #1,d7
cmp.b #'$',0(a0)
bne.s rh3
addq #1,a0
rh3 moveq #0,d0
cmpi.b #10,0(a0)
beq.s rherr
lea hextab(pc),a1
rh0 move.b (a0)+,d3
moveq.l #15,d2
rh1 cmp.b 0(a1,d2),d3
beq.s rh2
dbf d2,rh1
bra rhend
rh2 lsl.l #4,d0
or.b d2,d0
bra.s rh0
rhend tst.b d3
beq.s rhok
cmpi.b #10,d3
beq.s rhok
cmpi.b #' ',d3
beq.s rhok
rherr moveq #0,d7
rhok movem.l (a7)+,d1-d6/a1-a5
rts
;skip blanks
;a0 pointer to text
; returns a0 = new pointer position
kllblnks cmpi.b #' ',0(a0)
bne.s gn4
addq #1,a0
bra.s kllblnks
; exit program. If background flag is set, wait for
; amiga-amiga-x
stopall addq #4,a7
bra exitall
exit tst.b background
bne quithold
exitall bsr killpage
bsr freeblank
bsr killhistory
move.l stplist(PC),a3
tst.l 0(a3)
beq.s ex0
move.l a3,d0
bsr waok
bra.s exitall
ex0 tst.b background
beq.s ex1
bsr removeh
ex1 move.l _SysBase(PC),a1
move.l #_LVOSwitch,a0
move.l oldswitch,d0
CALL SetFunction,_SysBase(PC)
moveq #3,d0
lea IOCounter(PC),a1
CALL RemIntServer,_SysBase(PC)
move.l replyport(PC),-(a7)
LIBCALL DeletePort
addq #4,a7
bsr stoptimer
lea timerio,a1
CALL CloseDevice,_SysBase(PC)
move.l timerport(PC),-(a7)
LIBCALL DeletePort
addq #4,a7
bsr restoretrap
tst.l wnptr
beq.s 5$
move.l wnptr(PC),a0
CALL CloseWindow,intuibase(PC)
5$ move.l screenptr(PC),d0
beq.s 6$
move.l d0,a0
CALL CloseScreen,intuibase(PC)
clr.l screenptr
6$ move.l infile(PC),d1
beq.s ex11
CALL Close,dosbase(PC)
ex11 bsr freehidmem
bsr freealias
bsr clrfkeys
move.l realstack(PC),a7
IFND DEBUG
CALL Forbid,_SysBase(PC)
move.l wbmsg(PC),d0
beq.s todos
move.l d0,a1
CALL ReplyMsg,_SysBase(PC)
moveq #0,d0
rts
todos move.l mytask(PC),a0
move.l 152(a0),d1
CALL UnLock,dosbase(PC)
move.l myseg(PC),d1
CALL UnLoadSeg,dosbase(PC)
ENDC
moveq #0,d0
rts
;print a bcpl-string
;d0 = bcpl-pointer to bcpl-string
putbcpl movem.l d3/a0-a1,-(a7)
tst.l d0
beq.s pb1
lsl.l #2,d0
move.l d0,a1
moveq #0,d3
move.b (a1)+,d3
subq #1,d3
move.l ptr(PC),d0
lea out,a0
pb2 move.b (a1)+,0(a0,d0)
beq.s 1$
addq.b #1,d0
dbf d3,pb2
1$ move.l d0,ptr
pb1 movem.l (a7)+,d3/a0-a1
rts
;compare strings
;a0/a1 = pointers to string
;returns d0 = true(0) false(1), d1 = length
strcmp movem.l a0-a1,-(a7)
moveq #0,d0
move.l d0,d1
src2 move.b (a0)+,d0
beq.s src1
cmp.b #10,d0
beq.s src1
addq #1,d1
cmp.b (a1)+,d0
beq.s src2
bra.s src3
src1 move.b 0(a1),d0
src3 movem.l (a7)+,a0-a1
rts
strbuf movem.l d0/a1-a2,-(a7)
move.l a0,a1
lea buffer,a2
1$ move.b (a1)+,d0
cmp.b #10,d0
beq.s 2$
cmp.b #' ',d0
beq.s 2$
or.b #' ',d0
beq.s 2$
move.b d0,(a2)+
bra.s 1$
2$ clr.b (a2)+
movem.l (a7)+,d0/a1-a2
rts
;compare bcpl string with string
;a0 = pointer to string
;a2 = bcpl-pointer to bcpl-string
;returns d0 = true(0) false(1)
strbcmp movem.l d1/a0/a2,-(a7)
moveq #0,d0
moveq #0,d1
adda.l a2,a2
adda.l a2,a2
move.b (a2)+,d1
beq.s stb1
subq #1,d1
stb2 cmp.b (a2)+,(a0)+
bne.s stb1
dbf d1,stb2
moveq #1,d0
stb1 movem.l (a7)+,d1/a0/a2
rts
;add a fkey definition to the fkey list. Each entry
;looks like this: long Succ, long Pred, byte Key#, byte length,
; char text[]
setfkey bsr nodenam
move.b procnum(PC),d5
beq syntax
cmp.b #21,d5
bge syntax
subq #1,d5
move.b d5,procnum
lea fkeys(PC),a1
1$ move.l 0(a1),a1
tst.l 0(a1)
beq.s 2$
cmp.b 8(a1),d5
bne.s 1$
move.l a1,d3
CALL Remove,_SysBase(PC)
move.l d3,a1
bsr removefkey
2$ tst.b 0(a5)
beq.s 4$
move.l a5,a0
bsr strlen
move.l d0,d5
add.w #10,d0
moveq #0,d1
CALL AllocMem,_SysBase(PC)
tst.l d0
beq.s 4$
move.l d0,a1
move.l d0,a4
move.b procnum(PC),8(a1)
move.b d5,9(a1)
lea fkeys(PC),a0
CALL AddHead,_SysBase(PC)
lea 10(a4),a4
subq #1,d5
3$ move.b (a5)+,(a4)+
dbeq d5,3$
4$ rts
clrfkeys lea fkeys(PC),a0
CALL RemHead,_SysBase(PC)
tst.l d0
beq.s 1$
move.l d0,a1
bsr removefkey
bra.s clrfkeys
1$ rts
removefkey move.b 0(a1),d0
ext.w d0
ext.l d0
add.w #10,d0
CALL FreeMem,_SysBase(PC)
rts
;convert long to decimal
;d0 = value
;d3 bit 0 = left/right justified
;d3 bit 1 = write/leave
;returns string in 'buffer'
longdec movem.l d1-d2/a1-a2,-(a7)
tst.l d0
bmi.s 2$
cmp.l #9999999,d0
ble.s 1$
2$ move.l #smallnix,d0
bra.s ld6
1$ lea binarea+8(PC),a1
move.l #' ',-8(a1)
move.l #' ',-4(a1)
clr.b 0(a1)
subq #1,a1
cmp #2,d3
bne.s ld5
clr.b 0(a1)
ld5 moveq #1,d2
ld2 addq #1,d2
moveq #$a,d1
bsr div
addi.l #$30,d1
move.b d1,-(a1)
tst.l d0
bne.s ld2
btst #0,d3
bne.s ld1
lea binarea(PC),a2
cmpa.l a2,a1
bne.s ld3
subq.l #1,ptr
bra.s ld1
ld3 move.b 0(a1),(a2)+
move.b #' ',(a1)+
dbf d2,ld3
ld1 cmp #2,d3
beq.s ld4
move.l #binarea,d0
ld6 bsr putstr
ld4 movem.l (a7)+,d1-d2/a1-a2
rts
;write UBYTE
;d3 = value
bytedec bsr dec
move.l #decimal,d0
bra.s pm1
;write signed byte
;d3 = value
plusmins movem.l d5/a3,-(a7)
move.w #$2020,minus
move.b d3,d5
bpl.s 2$
neg.b d3
2$ bsr.s dec
tst.b d5
bpl.s 1$
move.l d0,a3
move.b #'-',-(a3)
1$ movem.l (a7)+,d5/a3
move.l #minus+1,d0
pm1 bra putstr
dec movem.l d3/a3,-(a7)
move.l #$20202020,decimal
and.l #$ff,d3
lea decimal+3(PC),a3
bloop tst.b d3
beq.s bend
divu #10,d3
swap d3
ori.b #'0',d3
move.b d3,-(a3)
clr.w d3
swap d3
bra.s bloop
bend cmpa.l #decimal+3,a3
bne 1$
move.b #'0',-(a3)
1$ move.l a3,d0
movem.l (a7)+,d3/a3
rts
;write a string, move cursor into next line
;d0 = pointer to text
putnam bsr putstr
putnam1 tst.b d0
beq.s ncr
bsr newline
ncr rts
;write one char
;d0 = char
putchar movem.l d1/a0,-(a7)
move.l ptr(PC),d1
lea out,a0
move.b d0,0(a0,d1)
addq.l #1,ptr
movem.l (a7)+,d1/a0
rts
;write a string, strings are only put into the output buffer when
;a LF is detected
;d0 = pointer to string
;returns d0 = cursor position
putstr movem.l d1-d7/a0-a6,-(a7)
move.b #1,printed
move.l d0,a2
lea out,a3
move.l ptr(PC),d0
move.l a2,d5
bne pst1
lea longnix(PC),a2
pst1 move.b (a2)+,d1
cmpi.b #13,d1
beq pst1
cmpi.b #10,d1
beq.s lineend
move.b d1,0(a3,d0)
beq prend
cmp #100,d0
bge.s pst1
addq #1,d0
bra.s pst1
lineend tst.b fromfile
beq.s 1$
moveq #0,d0
bra prend
1$ tst.l lastprinted
bne.s 2$
bsr killpage
2$ addq #1,d0
move.l d0,-(a7)
add #14,d0
moveq #0,d1
CALL AllocMem,_SysBase(PC)
move.l (a7)+,d1
tst.l d0
beq prend
move.l d0,a0
move.w d1,12(a0)
cmp.w maxllength(PC),d1
ble.s 7$
move.w d1,maxllength
7$ move.l node,8(a0)
clr.l node
clr.l 0(a0)
move.l lastprinted(PC),d0
move.l d0,4(a0)
bne.s 3$
move.l a0,outchain
bra.s 4$
3$ move.l d0,a1
move.l a0,0(a1)
4$ move.l a0,lastprinted
move.b #' ',14(a0)
subq #1,d1
lea 15(a0),a0
lea out,a1
subq #1,d1
bmi.s 6$
5$ move.b (a1)+,(a0)+
dbf d1,5$
6$ move.l numlines(PC),d2
cmp.l maxlines(PC),d2
ble.s 8$
move.l outchain(PC),a1
move.l 0(a1),a2
move.l a2,outchain
clr.l 4(a2)
move.w 12(a1),d0
add.w #14,d0
ext.l d0
CALL FreeMem,_SysBase(PC)
bra.s 9$
8$ addq.l #1,d2
move.l d2,numlines
9$ moveq #0,d0
move.l d0,d5
tst.b addlines
beq pst1
bsr addline
bra pst1
prend move.l d0,ptr
movem.l (a7)+,d1-d7/a0-a6
rts
;Kill output buffer
killpage movem.l d0-d7/a0-a6,-(a7)
tst.l outchain
beq.s 2$
move.l outchain(PC),a1
bsr killlines
clr.l outchain
clr.l lastprinted
clr.l numlines
clr.w maxllength
2$ movem.l (a7)+,d0-d7/a0-a6
rts
;kill the remainder of the output buffer
killlines move.l 0(a1),-(a7)
move.w 12(a1),d0
ext.l d0
add #14,d0
CALL FreeMem,_SysBase(PC)
move.l (a7)+,a1
move.l a1,d7
bne.s killlines
rts
freeblank move.l blanks(PC),d0
beq.s 1$
move.l d0,a1
move.w colms(PC),d0
ext.l d0
CALL FreeMem,_SysBase(PC)
clr.l blanks
1$ rts
;write a portion of the output buffer to the screen
blastout move.l rastport(PC),a1
moveq #1,d0
CALL SetAPen,gfxbase(PC)
move.l rastport(PC),a1
moveq #1,d0
CALL SetDrMd,gfxbase(PC)
moveq #0,d7
move.w loffset(PC),d2
beq.s 7$
move.w colms(PC),d4
add.w d4,d2
move.w maxllength(PC),d3
cmp.w d3,d2
ble.s 7$
move.w d3,d2
sub.w d4,d2
bpl.s 8$
moveq #0,d2
8$ move.w d2,loffset
7$ bsr tstfirstlin
1$ tst.l outchain
beq.s 3$
bsr findline
2$ move.w colms(PC),d5
ext.l d5
move.w loffset(PC),d4
ext.l d4
moveq #18,d6
6$ lea 14(a5,d4),a0
move.w 12(a5),d3
ext.l d3
bsr blastline
bge.s 3$
tst.l 0(a5)
beq.s 5$
move.l 0(a5),a5
bra 6$
5$ moveq #0,d3
bsr blastline
bcs.s 5$
3$ rts
;get a pointer to a line (line # in d0)
findline move.l outchain(PC),d1
beq 2$
move.l d1,a5
1$ tst d0
beq.s 2$
tst.l 0(a5)
beq.s 2$
move.l 0(a5),a5
dbf d0,1$
2$ rts
;check if the display is as 'full' as possible
tstfirstlin move.l firstline(PC),d0
move.l d0,d2
add.w rows(PC),d2
cmp.l numlines(PC),d2
bmi.s 1$
move.l numlines(PC),d2
sub.w rows(PC),d2
bpl.s 4$
moveq #0,d2
4$ move.l d2,d0
move.l d2,firstline
1$ rts
;display one line, fill the gap between the end of the line and
;the end of the window with spaces.
;d6 = ypos, d5=colms, d3= linelength, d7= line # in window, a0 = text
blastline move d6,d1
moveq #6,d0
move.l rastport(PC),a1
CALL Move,gfxbase(PC)
sub.w d4,d3
bpl.s 7$
moveq #0,d3
bra.s 6$
7$ cmp.w d5,d3
bmi.s 4$
move.w d5,d3
4$ move.l d3,d0
beq.s 6$
move.l rastport(PC),a1
CALL Text,gfxbase(PC)
6$ move.l d5,d0
sub.l d3,d0
ble.s 5$
move.l blanks(PC),a0
move.l rastport(PC),a1
CALL Text,gfxbase(PC)
5$ addq #8,d6
addq #1,d7
cmp.w rows(PC),d7
rts
;Write pointer, display '-------' if empty
hexan tst.l d0
bne.s hexa
bra putstr
;Write 8 byte hex value
;d0 = value
hexa bsr gthex
bra putstr
gthex movem.l d1-d7/a0-a6,-(a7)
moveq.l #7,d5
lea hexarea(PC),a1
lea hextab(PC),a0
moveq #0,d2
hexloop move.b d0,d2
and.b #15,d2
move.b 0(a0,d2),0(a1,d5)
lsr.l #4,d0
dbf d5,hexloop
move.l a1,d0
movem.l (a7)+,d1-d7/a0-a6
rts
;Convert/write byte into binary string
;d0 = value
bin movem.l d1-d7/a0-a6,-(a7)
lea binarea(PC),a0
move.w #$2020,8(a0)
moveq.l #7,d4
binloop moveq.l #'0'/2,d1
roxr.b #1,d0
roxl.b #1,d1
move.b d1,0(a0,d4)
dbf d4,binloop
move.l a0,d0
movem.l (a7)+,d1-d7/a0-a6
bra putstr
;send a packet
;a0 = msgport
;dp_Type and dp_Arg1 have to be inizialized
cons1 movem.l d0-d7/a0-a6,-(a7)
move.l #dp_Link,LN_NAME
move.l #mypacket,dp_Link
move.l replyport(PC),dp_Port
lea mypacket,a1
CALL PutMsg,_SysBase(PC)
move.l replyport,a0
CALL WaitPort,_SysBase(PC)
move.l replyport(PC),a0
CALL GetMsg,_SysBase(PC)
movem.l (a7)+,d0-d7/a0-a6
rts
;32-bit division
;d0 / d1
;returns d0
div movem.l d2-d3,-(a7)
tst.l d1
beq div8
swap d1
move.w d1,d2
bne.s div1
swap d0
swap d1
swap d2
move.w d0,d2
beq.s div2
divu d1,d2
move.w d2,d0
div2 swap d0
move.w d0,d2
divu d1,d2
move.w d2,d0
swap d2
move.w d2,d1
bra div8
div1 moveq #$10,d3
cmpi.w #$80,d1
bcc.s div3
rol.l #8,d1
subq.w #8,d3
div3 cmpi.w #$800,d1
bcc.s div4
rol.l #4,d1
subq.w #4,d3
div4 cmpi.w #$2000,d1
bcc.s div5
rol.l #2,d1
subq.w #2,d3
div5 tst.w d1
bmi.s div6
rol.l #1,d1
subq.w #1,d3
div6 move.w d0,d2
lsr.l d3,d0
swap d2
clr.w d2
lsr.l d3,d2
swap d3
divu d1,d0
move.w d0,d3
move.w d2,d0
move.w d3,d2
swap d1
mulu d1,d2
sub.l d2,d0
bcc.s div7
subq.w #1,d3
add.l d1,d0
div7 moveq #0,d1
move.w d3,d1
swap d3
rol.l d3,d0
swap d0
exg d1,d0
div8 movem.l (a7)+,d2-d3
rts
;install a input-handler
installh pea 0
pea xopsleep
LIBCALL CreatePort
addq #8,a7
move.l d0,InputMsg
move.l d0,-(a7)
LIBCALL CreateStdIO
addq #4,a7
move.l d0,InRequest
move.l d0,a1
lea devicenam(PC),a0
moveq #0,d0
moveq #0,d1
CALL OpenDevice,_SysBase(PC)
move.l d0,devstatus
movea.l InRequest(PC),a1
move.l #InInterrupt,40(a1)
move.w #9,28(a1)
CALL DoIO,_SysBase(PC)
move.l d0,iostatus
move.l #-1,d0
CALL AllocSignal,_SysBase(PC)
moveq #0,d1
bset d0,d1
move.l d1,mysignal
rts
;remove handler
removeh movea.l InRequest(PC),a1
move.l #InInterrupt,40(a1)
move.w #10,28(a1)
CALL DoIO,_SysBase(PC)
movea.l InRequest(PC),a1
CALL CloseDevice,_SysBase(PC)
move.l InRequest,-(a7)
LIBCALL DeleteStdIO
addq #4,a7
move.l InputMsg,-(a7)
LIBCALL DeletePort
addq #4,a7
rts
;this is the handler, it checks if amiga-amiga-x
;has been pressed and signals it to our task
Keyhandler tst.b running
bne.s endhandler
cmp.b #1,4(a0)
bne.s endhandler
move.w 8(a0),d0
andi.w #$c0,d0
cmpi.w #$c0,d0
bne.s endhandler
cmp.w #$32,6(a0)
bne.s endhandler
wakeup move.l a0,-(a7)
movea.l mytask(PC),a1
move.l mysignal(PC),d0
CALL Signal,_SysBase(PC)
move.l (a7)+,a0
clr.b 4(a0)
endhandler move.l a0,d0
rts
snoop bsr cls
bsr nodenam
moveq #1,d7
lea TReNode(PC),a4
bsr findnam
tst.b d7
bne.s 1$
move.l #stperr,d0
bra putnam
1$ move.l d0,captask
pea 0
pea memportname
LIBCALL CreatePort
addq #8,a7
move.l d0,snoopport
beq tm6
bsr replyintui
move.b #1,addlines
lea snoophead(PC),a0
bsr puthead
move.l _SysBase(PC),a1
move.l -196(a1),oldalloc
move.l -208(a1),oldfree
move.l #capmalloc,d0
move.l #-198,a0
CALL SetFunction,_SysBase(PC)
move.l _SysBase(PC),a1
move.l #capmfree,d0
move.l #-210,a0
CALL SetFunction,_SysBase(PC)
clr.b bool
clr.b cbreak
waitmem move.l snoopport(PC),a0
moveq #0,d1
move.b 15(a0),d1
bset d1,d0
move.l d0,auxsig
bsr processmsgs
tm7 move.l mytask(PC),a0
move.l snoopport(PC),a0
CALL GetMsg,_SysBase(PC)
tst.l d0
bne tm8
tst.b cbreak
bne snoopend
bra waitmem
tm8 move.l d0,a3
move.l 20(a3),d3
btst #31,d3
beq freed
move.l #allok,d0
bsr putstr
lea memname(PC),a2
lea membit(PC),a4
moveq #4,d5
tm2 move.l 0(a4),d4
btst d4,d3
beq.s tm1
move.l 0(a2),d0
bsr putstr
tm1 addq #4,a2
addq #4,a4
dbf d5,tm2
moveq #26,d1
bsr tab
move.l 24(a3),d0
move.l d0,d3
bsr hexa
move.l 28(a3),d0
bne.s tm3
move.l #failed,d0
bsr putstr
moveq #53,d1
bsr tab
bra tm4
tm3 bsr hexa
move.l 28(a3),d0
add.l d3,d0
bsr hexa
bra tm4
freed move.l #free,d0
bsr putstr
move.b #'-',d0
moveq #18,d1
tm9 bsr putchar
dbf d1,tm9
move.b #' ',d0
bsr putchar
move.l d3,d0
bsr hexa
move.l 24(a3),d0
bsr hexa
move.l 24(a3),d0
add.l d3,d0
bsr hexa
tm4 move.l 32(a3),d0
bsr hexa
bsr newline
move.w 18(a3),d0
ext.l d0
move.l a3,a1
CALL FreeMem,_SysBase(PC)
bra tm7
snoopend move.l _SysBase(PC),a1
move.l oldalloc(PC),d0
move.l #-198,a0
CALL SetFunction,_SysBase(PC)
move.l _SysBase(PC),a1
move.l oldfree,d0
move.l #-210,a0
CALL SetFunction,_SysBase(PC)
move.l snoopport,-(a7)
LIBCALL DeletePort
addq #4,a7
move.l #stoped,d0
bsr putnam
clr.b addlines
clr.l auxsig
tm6 rts
memname dc.l memlarg,memclr,memfast,memchip,mempubl
membit dc.l 17,16,2,1,0
capmalloc movem.l d0-d7/a0-a6,-(a7)
move.l _SysBase(PC),a6
move.l 276(a6),d4
cmp.l captask(PC),d4
bne.s capm1
tst.b bool
bne capm1
move.b #1,bool
moveq #36,d6
bsr allocmsg
beq capm2
bset #31,d1
move.l d1,20(a5)
move.l d0,24(a5)
move.l 60(a7),32(a5)
move.l a5,remembr
movem.l (a7)+,d0-d7/a0-a6
bsr memalloc
movem.l d0-d7/a0-a6,-(a7)
move.l remembr(PC),a1
move.l d0,28(a1)
move.l snoopport,a0
move.b #5,8(a1)
CALL PutMsg,_SysBase(PC)
clr.b bool
movem.l (a7)+,d0-d7/a0-a6
rts
capm2 clr.b bool
capm1 movem.l (a7)+,d0-d7/a0-a6
memalloc dc.w $4ef9
oldalloc dc.l 0
capmfree movem.l d0-d7/a0-a6,-(a7)
move.l _SysBase(PC),a6
move.l 276(a6),d4
cmp.l captask(PC),d4
bne.s capf1
tst.b bool
bne.s capf1
move.b #1,bool
moveq #36,d6
bsr allocmsg
beq.s capf2
move.l d0,20(a5)
move.l a1,24(a5)
move.l 60(a7),32(a5)
move.l snoopport,a0
move.b #5,8(a5)
move.l a5,a1
CALL PutMsg,_SysBase(PC)
capf2 clr.b bool
capf1 movem.l (a7)+,d0-d7/a0-a6
dc.w $4ef9
oldfree dc.l 0
allocmsg movem.l d0-d1/a0-a1,-(a7)
move.l d6,d0
move.l #65536,d1
bsr memalloc
tst.l d0
beq.s alm1
move.l d0,a5
move.w d6,18(a5)
alm1 movem.l (a7)+,d0-d1/a0-a1
move.l a5,d6
rts
myswitch movem.l d0-d1/a0-a1,-(a7)
move.l _SysBase(PC),a0
move.l 276(a0),d0
move.l tasksnum(PC),d1
lea cputime,a0
subq.l #1,d1
bmi.s swadd
sw0 cmp.l (a0)+,d0
dbeq d1,sw0
tst d1
bmi.s swadd
swi1 add.l #1,508(a0)
swgo movem.l (a7)+,d0-d1/a0-a1
dc.w $4ef9
oldswitch dc.l 0
swadd cmp.l #125,tasksnum
bge.s swgo
addq.l #1,tasksnum
move.l d0,0(a0)
move.l #1,512(a0)
bra.s swgo
countio addq.l #1,iocount
moveq #0,d0
cio1 rts
iconbackdrp tst.b iconifyon
beq.s 1$
lea icnwindow,a0
eor.l #$100,14(a0) ;wn_Flags
1$ rts
iconifyoff tst.b iconifyon
beq.s cio1
clr.b iconifyon
tst.b fromfile
bne.s 1$
move.l wnptr(PC),d0
beq.s 1$
move.l d0,a0
lea iconifgad,a1
CALL RemoveGadget,intuibase(PC)
move.l wnptr(PC),a0
CALL RefreshWindowFrame,intuibase(PC)
1$ move.l #iconify,d0
killseg movem.l d1-d2/a0-a4,-(a7)
subq #4,d0
move.l 4,a6
move.l 276(a6),a4
move.l 128(a4),d1
lsl.l #2,d1
move.l d1,a3
move.l 12(a3),d1
bne.s 2$
move.l 172(a4),d1
lsl.l #2,d1
move.l d1,a4
move.l 60(a4),d1
2$ lsl.l #2,d1
cmp.l d0,d1
beq.s 4$
move.l d1,a4
move.l 0(a4),d1
beq.s 5$
bra.s 2$
4$ move.l d1,a0
move.l 0(a0),0(a4)
clr.l 0(a0)
lsr.l #2,d1
CALL UnLoadSeg,dosbase(PC)
movem.l (a7)+,d1-d2/a0-a4
5$ rts
alert bsr stoptimer
move.l excpttask(PC),d0
bne.s alert1
move.l #noguru,d0
bra putnam
alert1 move.l #softfail,d0
bsr putstr
move.l excpttask(PC),a0
move.l 10(a0),d0
bsr putnam
cmp.l #3,excpterror
bne.s 1$
move.l #addrserr,d0
bsr putstr
move.l excptaddr(PC),d0
bsr hexa
bsr newline
1$ move.l #procount,d0
bsr putstr
move.l excptpc(PC),d0
bsr hexa
bsr newline
move.l #gurutxt,d0
bsr putstr
move.l excpterror(PC),d0
bsr hexa
lea out,a0
move.l ptr(PC),d0
move.b #'.',-1(a0,d0)
move.l excpttask(PC),d0
bsr hexa
bra newline
showguru bsr alert
tst.b ownscreen
bne.s 5$
move.l wnptr(PC),a0
CALL WindowToFront,intuibase(PC)
bra.s 2$
5$ move.l screenptr,a0
CALL ScreenToFront,intuibase(PC)
2$ move.l #whatnow,d0
bsr putnam
clr.l oldpageend
bsr readline
cmp.b #'i',inputbuffer
beq.s 4$
1$ cmp.b #'k',inputbuffer
bne.s 2$
move.l excpttask(PC),a1
tst.l 22(a1)
bne.s 3$
CALL RemTask,_SysBase(PC)
bra.s 4$
3$ move.l a1,d0
bsr canok
4$ clr.l lastprinted
rts
myaddtask move.l a3,-(a7)
lea mytrap(PC),a3
move.l 50(a1),d0
beq.s 1$
cmp.l oldtrap(PC),d0
beq.s 1$
lea myproctrap(PC),a3
cmp.l oldproctrap(PC),d0
bne.s 2$
1$ move.l a3,50(a1)
2$ move.l (a7)+,a3
dc.w $4ef9
OldAddTask dc.l 0
myproctrap bsr traphandle
dc.w $4ef9
oldproctrap dc.l 0
mytrap bsr traphandle
moveq #0,d0
CALL Wait,_SysBase(PC)
dc.w $4ef9
oldtrap dc.l 0
traphandle movem.l d0-d7/a0-a6,$180
move.l 4,a6
move.l 276(a6),excpttask
move.l 4(a7),d0
cmp.l #9,d0
beq.s 2$
move.l d0,excpterror
moveq #10,d1
cmp.l #3,d0
bne.s 1$
move.l 0(a7,d1.w),excptaddr
moveq #18,d1
1$ move.l 0(a7,d1.w),excptpc
move.l mytask(PC),a1
move.l trapsignal(PC),d0
jsr _LVOSignal(a6)
2$ movem.l $180,d0-d7/a0-a6
rts
trapguru tst.b wanttraps
bne restoretrap
move.b #1,wanttraps
addtraps tst.b wanttraps
beq 5$
move.l 304(a6),oldtrap ;Original EXEC trap handler
moveq #-1,d0
CALL AllocSignal,_SysBase(PC)
moveq #0,d1
bset d0,d1
move.l d1,trapsignal
move.l #_LVOAddTask,a0 ;need a new AddTask() to change
move.l 2(a6,a0),OldAddTask ;AmigaDos's default trap handler
move.l a6,a1
move.l #myaddtask,d0
CALL SetFunction,_SysBase(PC)
CALL Forbid,_SysBase(PC) ;change the trap handler of
moveq #0,d5 ;aleady running tasks
bsr getaskdat ;get task stucture pointers
1$ tst.b entries
beq.s 2$
lea -16(a5),a5
move.l 0(a5),a4 ;pointer to a task structure
lea myproctrap(PC),a0
move.l 50(a4),d0 ;Task->tc_TrapCode
cmp.l oldproctrap(PC),d0 ;AmigaDos Handler ?
beq.s 3$
lea mytrap(PC),a0 ;EXEC Handler ?
cmp.l oldtrap(PC),d0
bne.s 4$ ;must be a custom one, skip it
3$ move.l a0,50(a4) ;replace it
4$ subq.b #1,entries
bra.s 1$
2$ CALL Permit,_SysBase(PC)
5$ rts
restoretrap tst.b wanttraps
beq.s 6$
tst.b fromfile
bne.s 5$
move.l #_LVOAddTask,a0
move.l OldAddTask(PC),d0
move.l _SysBase(PC),a1
CALL SetFunction,_SysBase(PC)
CALL Forbid,_SysBase(PC)
bsr getaskdat
1$ tst.b entries
beq.s 2$
lea -16(a5),a5
move.l 0(a5),a4
move.l oldproctrap(PC),a0
move.l 50(a4),d0
cmp.l #myproctrap,d0
beq.s 3$
move.l oldtrap(PC),a0
cmp.l #mytrap,d0
bne.s 4$
3$ move.l a0,50(a4)
4$ subq.b #1,entries
bra.s 1$
2$ CALL Permit,_SysBase(PC)
clr.l trapsignal
5$ clr.b wanttraps
6$ rts
;save the contents of the output buffer
;to a file
saveoutput bsr nodenam2
tst.b 0(a5)
beq syntax
move.l a5,d1
move.l #1006,d2
CALL Open,dosbase(PC)
move.l d0,d5
bne.s 1$
move.l #openerr,d0
bsr putstr
move.l a5,d0
bra putnam
1$ move.l outchain(PC),d0
beq.s 3$
2$ move.l d0,a5
move.w 12(a5),d3
beq.s 4$
ext.l d3
lea 14(a5),a1
move.l a1,d2
move.l d5,d1
CALL Write,dosbase(PC)
tst.l d0
ble.s 3$
4$ moveq #1,d3
move.l d5,d1
move.l #cr,d2
CALL Write,dosbase(PC)
tst.l d0
ble.s 3$
move.l 0(a5),d0
bne.s 2$
3$ move.l d5,d1
CALL Close,dosbase(PC)
rts
grabtimerio lea tiohead(PC),a0
bsr puthead
move.b timeout(PC),d4
move.b #255,timeout
bsr starttimer
move.b d4,timeout
lea timerio,a1
CALL Disable,_SysBase(PC)
2$ move.l 0(a1),d2
beq.s 1$
move.l d2,a1
bra.s 2$
1$ CALL Enable,_SysBase(PC)
lea -4(a1),a5
bsr stoptimer
lea buffer,a4
moveq #1,d4
bsr gettrq
lea timerio,a0
lea dummy,a1
moveq #40,d0
CALL CopyMem,_SysBase(PC)
lea dummy,a1
lea timernam(PC),a0
moveq #0,d1
moveq #0,d0
CALL OpenDevice,_SysBase(PC)
lea dummy,a1
move.l #1<<30,32(a1)
CALL SendIO,_SysBase(PC)
lea dummy,a5
CALL Disable,_SysBase(PC)
8$ move.l 0(a5),d2
beq.s 7$
move.l d2,a5
bra.s 8$
7$ CALL Enable,_SysBase(PC)
lea -4(a5),a5
lea dummy,a1
CALL AbortIO,_SysBase(PC)
lea timerio,a1
CALL WaitIO,_SysBase(PC)
move.w timersig,d0
moveq #0,d1
bset d0,d1
moveq #0,d0
CALL SetSignal,_SysBase(PC)
moveq #0,d4
bsr gettrq
lea dummy,a1
CALL CloseDevice,_SysBase(PC)
clr.l (a4)+
lea -22(a4),a2
moveq #18,d2
bsr sortlist
lea buffer,a5
5$ move.l (a5)+,d0
beq.s 6$
bsr hexa
move.w (a5)+,d0
ext.l d0
mulu #9,d0
add.l #timerunits,d0
bsr putstr
move.l (a5)+,d3
mulu #10,d3
move.l (a5)+,d0
move.l #100000,d1
bsr div
add.l d3,d0
cmp.l #2559,d0
ble.s 9$
move.l #whatsthis,d0
bsr putstr
bra.s 10$
9$ moveq #1,d6
bsr putfrac
10$ move.b #' ',d0
bsr putchar
move.l (a5)+,d0
bsr getaskname2
bsr newline
bra.s 5$
6$ rts
gettrq CALL Disable,_SysBase(PC)
3$ move.l 0(a5),a5
tst.l 0(a5)
beq.s 4$
move.l a5,(a4)+
move.w d4,(a4)+
move.l 32(a5),(a4)+
move.l 36(a5),(a4)+
move.l 14(a5),a1
move.l 16(a1),(a4)+
bra.s 3$
4$ CALL Enable,_SysBase(PC)
rts
;check if the timer is runnig, start it if not
starttimer lea timerio,a1
cmp.b #5,8(a1)
beq.s 1$
moveq #0,d0
move.b timeout(PC),d0
bne.s 2$
tst.l timeoutm
beq.s 1$
2$ move.l d0,32(a1)
move.l timeoutm(PC),36(a1)
move.w #9,28(a1)
CALL SendIO,_SysBase(PC)
1$ rts
;Abort a timer request, if pending
stoptimer lea timerio,a1
cmp.b #5,8(a1)
bne.s 1$
CALL AbortIO,_SysBase(PC)
lea timerio,a1
CALL WaitIO,_SysBase(PC)
1$ move.w timersig,d0
moveq #0,d1
bset d0,d1
moveq #0,d0
CALL SetSignal,_SysBase(PC)
rts
;Xoper main loop, process all incoming messages
processmsgs move.l wnptr(PC),a0
moveq #0,d0
move.w intuisig(PC),d1
bset d1,d0
move.w timersig(PC),d1
bset d1,d0
or.w #4096,d0
or.l auxsig(PC),d0
tst.l auxsig
bne.s 1$
or.l trapsignal(PC),d0
1$ CALL Wait,_SysBase(PC)
move.l d0,tasksigs
move.l trapsignal(PC),d1
and.l d0,d1
beq.s ctrl_c
tst.b gotguru
bne.s ctrl_c
move.b #1,gotguru
bsr showguru
clr.b gotguru
ctrl_c moveq #12,d1
bsr testsig
bne exit
timermsg move.w timersig(PC),d1
bsr testsig
beq intuimsgs
tst.w repeat
bne.s 1$
bsr showwhat
bra.s intuimsgs
1$ move.w repeatlen,d0
lea repeatbuffer,a2
lea dummy,a1
move.w d0,d1
2$ move.b (a2)+,(a1)+
dbf d1,2$
bsr cli
bsr starttimer
intuimsgs move.w intuisig(PC),d1
bsr testsig
beq processnxtmsg
nextimsg move.l wnptr(PC),a0
move.l $56(a0),a0
CALL GetMsg,_SysBase(PC)
tst.l d0
beq processnxtmsg
move.l d0,intuimsg
move.l d0,a0
move.l 20(a0),d0
cmp.l #$200,d0 ;CloseWindow
bne.s 1$
tst.b addlines
beq exitall
move.b #1,cbreak
bra intuiend
1$ cmp.l #2,d0 ;ResizeWindow
bne.s 2$
bsr setupscreen
bra intuiend
2$ cmp.l #4,d0 ;refresh
bne.s 22$
bsr putiline
bsr blastout
bsr UpdateIArea
bra intuiend
22$ tst.b addlines
bne 3$
cmp.l #$40,d0 ;gadgetup
bne.s 3$
tst.w getanswer
bne.s 3$
bsr replyintui
bsr stoptimer
bra instback
3$ cmp.l #$400,d0 ;RawKey
bne notarawkey
move.w #$80,d0
and.w 24(a0),d0
bne intuiend
and.w #$7f,24(a0)
lea ievent,a1
move.b #1,4(a1)
move.l 24(a0),6(a1)
move.w 26(a0),qualifier
move.l a1,a0
lea outevent,a1
moveq #20,d1
suba.l a2,a2
CALL RawKeyConvert,condev(PC)
tst.l d0
beq intuiend
lea inputbuffer,a1
lea outevent,a2
move.w curpos(PC),d4
moveq #0,d3
tst.b addlines
bne 197$
sub.w #1,cmdcompflag
cmp.b #$9b,0(a2) ;CSI
bne 110$
cmp.b #'?',1(a2) ;help
bne.s 399$
tst.w getanswer
bne.s 399$
bsr stoptimer
tst.w bottomin
bne.s 398$
move.w #1,bottomin
clr.w ibufferlen
clr.w curpos
bsr UpdateIArea
398$ move.l #usetxt,d0
bsr putnam
clr.l lastprinted
bsr blastout
bra.s 420$
399$ cmp.b #'C',1(a2) ;cursor right
bne.s 400$
cmp.w ibufferlen(PC),d4
bge.s 420$
addq #1,d4
421$ move.w d4,curpos
420$ bra 100$
400$ cmp.b #'D',1(a2) ;cursor left
bne.s 401$
subq #1,d4
bpl.s 421$
bra.s 420$
401$ cmp.b #' ',1(a2)
bne.s 402$
cmp.b #'@',2(a2) ;shift right
bne.s 403$
404$ cmp.w ibufferlen(PC),d4
bge.s 421$
addq #1,d4
cmp.b #' ',0(a1,d4)
bne.s 404$
405$ cmp.w ibufferlen(PC),d4
bge.s 421$
addq #1,d4
cmp.b #' ',0(a1,d4)
beq.s 405$
bra.s 421$
403$ cmp.b #'A',2(a2) ;shift left
bne.s 420$
406$ tst.w d4
beq.s 421$
subq #1,d4
cmp.b #' ',0(a1,d4)
beq.s 406$
407$ tst.w d4
beq.s 421$
subq #1,d4
cmp.b #' ',0(a1,d4)
bne.s 407$
addq #1,d4
bra.s 421$
402$ cmp.b #'A',1(a2) ;cursor up
bne.s 408$
tst.w bottomin
bne.s 480$
tst.w curpos
bne.s 480$
clr.w curpos
clr.w ibufferlen
bsr UpdateIArea
bsr clrcursor
move.w edline(PC),d3
ext.l d3
tst.w d3
beq.s 481$
subq #1,d3
cmp.l firstline(PC),d3
bge.s 481$
move.l d3,-(a7)
subq.l #1,firstline
bsr blastout
move.l (a7)+,d3
481$ move.w d3,edline
bsr getcurpos
bsr putcursor
bra intuiend
480$ move.l history(PC),a0
tst.l 0(a0)
beq.s 423$
move.l curhist(PC),a1
cmp.l a0,a1
beq.s 409$
move.l 4(a1),d0
move.l d0,curhist
409$ move.l a1,gothline
bsr copyhistory
423$ bra 100$
408$ cmp.b #'B',1(a2) ;cursor down
bne 410$
tst.w bottomin
bne.s 414$
tst.w curpos
bne.s 414$
clr.w curpos
clr.w ibufferlen
bsr UpdateIArea
bsr clrcursor
move.w edline(PC),d3
ext.l d3
move.l numlines(PC),d4
subq #1,d4
cmp.l d4,d3
beq.s 490$
move.l firstline(PC),d2
add.w rows(PC),d2
subq #1,d2
addq #1,d3
cmp.w d2,d3
ble.s 490$
move.l d3,-(a7)
addq.l #1,firstline
bsr blastout
move.l (a7)+,d3
490$ bra 481$
414$ move.l curhist(PC),d0
beq.s 423$
move.l d0,a1
move.l 0(a1),a1
tst.l 0(a1)
bne.s 411$
clr.l gothline
clr.w curpos
clr.w ibufferlen
bra 423$
411$ move.l a1,curhist
bra 409$
410$ cmp.b #'T',1(a2) ;shift up
bne.s 412$
tst.w hnum
beq 423$
move.l history(PC),a1
move.l a1,curhist
bra 409$
412$ cmp.b #'S',1(a2) ;shift down
bne.s 440$
tst.w hnum
beq 423$
move.l history+8,curhist
bra.s 414$
440$ cmp.b #'0',1(a2) ;function keys
bmi 423$
cmp.b #'9',1(a2)
bgt 423$
lea 1(a2),a0
bsr getnum
lea fkeys(PC),a0
441$ move.l 0(a0),a0
tst.l 0(a0)
beq 100$
cmp.b 8(a0),d2
bne.s 441$
move.b 9(a0),d5
ext.w d5
subq #1,d5
lea 10(a0),a0
move.w curpos(PC),d4
lea inputbuffer,a2
moveq #0,d3
lea 0(a2,d4),a2
445$ move.b (a0)+,d0
cmp.b #'^',d0
bne.s 442$
moveq #1,d3
bra.s 443$
442$ cmp.b #'_',d0
bne.s 444$
move.b #' ',d0
444$ move.b d0,(a2)+
addq #1,d4
443$ dbf d5,445$
move.w d4,curpos
cmp.w ibufferlen(PC),d4
ble.s 446$
move.w d4,ibufferlen
446$ tst d3
beq 100$
bra got_fkey
110$ moveq #0,d3
101$ move.w curpos(PC),d4
tst d0
beq 100$
cmp.b #13,0(a2,d3) ;return